package com.nmc.core.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.nmc.model.Employee;




public class EmployeeDAOImpl extends BaseDAO implements EmployeeDAO {

	
	public void createEmployee(Employee employee) {
        this.getHibernateTemplate().saveOrUpdate(employee);
		
	}

	public void updateEmployee(Employee employee) {
	        this.getHibernateTemplate().update(employee);
		
	}



	public List<Employee> getEmployeeList() {
		return this.getHibernateTemplate().loadAll(Employee.class);
	}
	
	public Employee getEmployeeById(String empId){
		
		Session session = this.getSession();
		
        Criteria c = session.createCriteria(Employee.class);
		c.add(Restrictions.like("empId",empId));

		if(c.list() != null && c.list().size() > 0)
			return (Employee)c.list().get(0);
		else {
			return null;	
		}
		
	
	}
	
}
